/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package QUERY;

import Utils.User;
import Utils.dbManager;

import java.sql.*;

/**
 *
 * @author Alice
 */
public class Query_User {
    public static User Query_user(String username, String password) throws SQLException
    {
    /**    String query= "SELECT TYPES"
                    + "FROM UTENTE"
                    + "WHERE USERNAME='"+username+"' AND PASSWORD='"+password+"' ";
        User tmp=null;
        try{
        Connection con = dbManager.getConnection();
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        }}}     
       **/ 

PreparedStatement stm = con.prepareStatement("SELECT TYPES"
                    + "FROM UTENTE"
                    + "WHERE USERNAME='"+username+"' AND PASSWORD='"+password+"' ";");
try {
ResultSet rs = stm.executeQuery();
try {
while(rs.next()) {
User u = new User();
u.getTypes(rs.getString("types"));

User.add(u);
}

} finally {
rs.close();
}
} finally {
stm.close();
}
return products;
}

/*if (query="buyer"){
            
        }
        
        while(rs.next())
        {
            types= rs.getString("TYPES");
            if(types="seller"){
            case 1: types= rs.getString("buyer"); break;
            case 2: types= rs.getString("seller"); break;
        }}
        tmp= new User(types,username,password);
        }
            catch(Exception e){
                e.printStackTrace();
            }
        return tmp;
        }
    }
    
**/
